package com.bert.feign.fallBackFactory;

import com.bert.entity.TestDemoEntity;
import com.bert.feign.TestClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class TestClientFallbackFactory implements FallbackFactory<TestClient> {

    @Override
    public TestClient create(Throwable cause) {
        return new TestClient() {
            @Override
            public String path(String number) {
                return "default path";
            }

            @Override
            public String param(Integer a, Integer b) {
                return "default param";
            }

            @Override
            public TestDemoEntity post(TestDemoEntity entity) {
                return new TestDemoEntity(0, "default post");
            }

            @Override
            public String notFound() {
                log.info("notFound");
                return "not found";
            }
        };
    }
}
